#ifndef JOB_HPP_INCLUDED
#define JOB_HPP_INCLUDED

#include <string>
#include <vector>

#include "boost/intrusive_ptr.hpp"
#include "boost/shared_ptr.hpp"

#include "formula_callable.hpp"
#include "job_fwd.hpp"
#include "wml_node_fwd.hpp"

namespace hex {
class tile;
}

class job_type;
typedef boost::shared_ptr<const job_type> const_job_type_ptr;

class job_type
{
public:
	static void init(wml::const_node_ptr node);
	static const_job_type_ptr get(const std::string& key);
	static const std::vector<const_job_type_ptr>& jobs();

	explicit job_type(wml::const_node_ptr node);

	const std::string& id() const;

private:
	std::string id_;
};

class job : public game_logic::formula_callable
{
public:
	job(const_job_type_ptr type, hex::tile* t)
	  : type_(type), pay_(0), positions_available_(0), positions_taken_(0), tile_(t)
	{}
	const const_job_type_ptr& type() const { return type_; }
	int pay() const { return pay_; }
	void set_pay(int amount) { pay_ = amount; }
	int positions_available() const { return positions_available_; }
	void set_positions_available(int num) { positions_available_ = num; }
	int positions_taken() const { return positions_taken_; }
	void set_positions_taken(int num) { positions_taken_ = num; }
	hex::tile* tile() { return tile_; }
	const hex::tile* tile() const { return tile_; }
private:
	variant get_value(const std::string& key) const;
	const_job_type_ptr type_;
	int pay_;
	int positions_available_;
	int positions_taken_;
	hex::tile* tile_;
};

#endif
